/*
 * Zhz.net Inc.
 * Copyright (c) 2010 All Rights Reserved.
 */
package com.zhz.project.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.zhz.project.dal.daointerface.WenzhangDAO;

// auto generated imports
import com.zhz.project.dal.dataobject.WenzhangDO;
import org.springframework.dao.DataAccessException;
import java.util.Map;
import java.util.HashMap;

/**
 * An ibatis based implementation of dao interface <tt>com.zhz.project.dal.daointerface.WenzhangDAO</tt>.
 *
 * This file is generated by <tt>paygw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/wenzhang.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>paygw-dalgen</tt> 
 * to generate this file.
 *
 * @author Li Wei
 */
public class IbatisWenzhangDAO extends SqlMapClientDaoSupport implements WenzhangDAO {
	/**
	 *  Query DB table <tt>wenzhang</tt> for records.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select * from wenzhang where (id = ?)</tt>
	 *
	 *	@param id
	 *	@return WenzhangDO
	 *	@throws DataAccessException
	 */	 
    public WenzhangDO getById(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return (WenzhangDO) getSqlMapClientTemplate().queryForObject("MS-WENZHANG-GET-BY-ID", param);

    }

	/**
	 *  Insert one <tt>WenzhangDO</tt> object to DB table <tt>wenzhang</tt>, return primary key
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into wenzhang(issueid,title,titleurl,author,abstracturl,fulltexturl,exone,extwo) values (?, ?, ?, ?, ?, ?, ?, ?)</tt>
	 *
	 *	@param wenzhang
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int insert(WenzhangDO wenzhang) throws DataAccessException {
    	if (wenzhang == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-WENZHANG-INSERT", wenzhang);

        return wenzhang.getId();
    }

	/**
	 *  Update DB table <tt>wenzhang</tt>.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update wenzhang set exone=? where (id = ?)</tt>
	 *
	 *	@param exone
	 *	@param id
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateExone(String exone, int id) throws DataAccessException {
        Map param = new HashMap();

        param.put("exone", exone);
        param.put("id", new Integer(id));

        return getSqlMapClientTemplate().update("MS-WENZHANG-UPDATE-EXONE", param);
    }

	/**
	 *  Update DB table <tt>wenzhang</tt>.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update wenzhang set extwo=? where (id = ?)</tt>
	 *
	 *	@param extwo
	 *	@param id
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateExtwo(String extwo, int id) throws DataAccessException {
        Map param = new HashMap();

        param.put("extwo", extwo);
        param.put("id", new Integer(id));

        return getSqlMapClientTemplate().update("MS-WENZHANG-UPDATE-EXTWO", param);
    }

}